//
//  RBCompeListController.m
//  RMMaterialRed
//
//  Created by XBWH on 2024/3/12.
//

#import "RBCompeListController.h"
#import "RBFootBallGameController.h"
#import "RBBasketBallGameController.h"

@interface RBCompeListController ()<JXCategoryViewDelegate>
@property(strong,nonatomic)UIView *navTitleView;
@property(strong,nonatomic)JXCategoryTitleView *compCategoryView;
@property(copy,nonatomic)NSString *searchSportId;
@property(strong,nonatomic)RBFootBallGameController *footBallGameVc;
@property(strong,nonatomic)RBBasketBallGameController *basketBallGameVc;
@property(copy,nonatomic)NSString *selectFootType;
@property(copy,nonatomic)NSString *selectBasType;
@end

@implementation RBCompeListController

- (instancetype)init {
    if ([super init]) {
        self.titles = @[@"足球",@"篮球"];
    }
    return self;
}

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:YES];
    
    [self.navigationController setNavigationBarHidden:YES animated:animated];
    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.searchSportId = @"1";
    [self rb_initNavViewUI];
    [self rb_initCategoryView];
}
-(void)rb_initNavViewUI{
    UIView *navBgView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, RBScreenWidth, RBNAVIGATION_BAR_HEIGHT)];
    navBgView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:navBgView];
    
    UIView *navTitleView = [[UIView alloc] init];
    [navBgView addSubview:navTitleView];
    self.navTitleView = navTitleView;
    [navTitleView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(0);
        make.bottom.mas_equalTo(0);
        make.width.mas_equalTo(RBScaleWidth(144));
        make.height.mas_equalTo(RBScaleWidth(44));
    }];
//    UIButton *screenButton = [UIButton buttonWithType:UIButtonTypeCustom];
//    [screenButton setImage:[UIImage imageNamed:@"dhl_sx"] forState:UIControlStateNormal];
//    [screenButton setImage:[UIImage imageNamed:@"dhl_sx"] forState:UIControlStateHighlighted];
//    [screenButton addTarget:self action:@selector(screenBtnClicked) forControlEvents:UIControlEventTouchUpInside];
//    [navBgView addSubview:screenButton];
//    [screenButton mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.right.mas_equalTo(-RBScaleWidth(10));
//        make.centerY.mas_equalTo(navTitleView.mas_centerY);
//    }];
//    UIButton *searchButton = [UIButton buttonWithType:UIButtonTypeCustom];
//    [searchButton setImage:[UIImage imageNamed:@"ss"] forState:UIControlStateNormal];
//    [searchButton setImage:[UIImage imageNamed:@"ss"] forState:UIControlStateHighlighted];
//    [searchButton addTarget:self action:@selector(searchBtnClicked) forControlEvents:UIControlEventTouchUpInside];
//    [navBgView addSubview:searchButton];
//    [searchButton mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.right.mas_equalTo(screenButton.mas_left).mas_offset(-RBScaleWidth(15));
//        make.centerY.mas_equalTo(navTitleView.mas_centerY);
//    }];
}
-(void)rb_initCategoryView{
    self.compCategoryView.titles = self.titles;
    self.compCategoryView.cellSpacing = 0;
    self.compCategoryView.cellWidth = RBScaleWidth(72);
    self.compCategoryView.titleSelectedFont = RBPingFangMediumFont(18);
    self.compCategoryView.titleFont = RBPingFangMediumFont(18);
    self.compCategoryView.titleSelectedColor = RBColor(51, 51, 51);
    self.compCategoryView.titleColor = RBColor(153, 153, 153);
    self.isHidBottomLineView = YES;
    [self.navTitleView addSubview:self.compCategoryView];
    [self.compCategoryView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.bottom.mas_equalTo(0);
    }];
}
- (JXCategoryTitleView *)compCategoryView {
    return (JXCategoryTitleView *)self.categoryView;
}
- (JXCategoryBaseView *)preferredCategoryView {
    return [[JXCategoryTitleView alloc] init];
}
- (CGFloat)preferredCategoryViewHeight{
    return 0;
}
- (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index{
    if (index == 0) {
        self.searchSportId = @"1";
    } else {
        self.searchSportId = @"2";
    }
    [self.compCategoryView reloadDataWithoutListContainer];
}
-(id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index {
    if (index == 0) {
        RBFootBallGameController *footBallVc = [[RBFootBallGameController alloc] init];
        footBallVc.sportId = @"1";
        footBallVc.type = @"2";
        self.searchSportId = @"1";
        self.footBallGameVc = footBallVc;
        return footBallVc;
    } else {
        RBBasketBallGameController *basBallVc = [[RBBasketBallGameController alloc] init];
        basBallVc.sportId = @"2";
        basBallVc.type = @"1";
        self.searchSportId = @"2";
        self.basketBallGameVc = basBallVc;
        return basBallVc;
    }
}

//-(void)screenBtnClicked{
//    
//}
//-(void)searchBtnClicked{
//    
//}

@end
